package com.lewis.module.m2.utils;

import com.lewis.common.core.entity.BaseResult;
import com.lewis.common.core.utils.SpringUtil;
import com.lewis.module.m2.api.integral.api.ImmortalIntegralApi;
import com.lewis.module.m2.api.integral.vo.ImmortalVo1;
import net.mamoe.mirai.event.events.MessageEvent;
import net.mamoe.mirai.message.data.At;
import net.mamoe.mirai.message.data.MessageChainBuilder;

/**
 * 积分操作工具类
 *
 * @author Lewis - 398529803@qq.com
 * @date 2022年2月9日, 009 - 11:09:51
 */
public class IntegralUtils {

	/**
	 * 消耗积分并且返回状态数据
	 *
	 * @param event
	 * @param qq
	 * @param num
	 * @return
	 */
	public static BaseResult cutIntegral(MessageEvent event, long qq, Integer num) {
		// 积分减num
		event.getSubject().sendMessage(new MessageChainBuilder()
				.append(new At(qq)).append("\n")
				.append("将使用[").append(String.valueOf(num)).append("]仙力执行本次操作......").build()
		);
		ImmortalVo1 vo = new ImmortalVo1();
		vo.setQq(String.valueOf(qq));
		vo.setGroupId(String.valueOf(event.getSubject().getId()));
		vo.setNum(num);
		return SpringUtil.getBean(ImmortalIntegralApi.class).cutImmortalIntegral(vo);
	}
}
